using System;

using EarthUtility;
using Unity.Mathematics;
using static Unity.Mathematics.math;
namespace EarthGeospatial
{
    public struct Cartographic
    {
        /**
         * @brief The longitude, in radians.
         */
        public double longitude;

        /**
         * @brief The latitude, in radians.
         */
        public double latitude;

        /**
         * @brief The height, in meters.
         */
        public double height;
        public Cartographic(
              double longitudeRadians,
              double latitudeRadians,
              double heightMeters = 0.0)
        {
            this.longitude = longitudeRadians;
            this.latitude = latitudeRadians;
            this.height = heightMeters;
        }

        public static Cartographic fromDegrees(
      double longitudeDegrees,
      double latitudeDegrees,
      double heightMeters = 0.0)
        {
            return new Cartographic(
                Mathd.degreesToRadians(longitudeDegrees),
                Mathd.degreesToRadians(latitudeDegrees),
                heightMeters);
        }

        public double3 ToDegrees()
        {
            return new double3(Mathd.radiansToDegrees(this.longitude), Mathd.radiansToDegrees(this.latitude), height);
        }

        public override string ToString()
        {
            return $"({longitude},{latitude},{height})";
        }
    }
}